<template>
	<view class="content">
	<!-- 正面 -->
	<jianweikaifa-idCardShooting 
	    :isFront="1" 
	    @idCardData="getIdCardData" 
	    @close="getClose">
	</jianweikaifa-idCardShooting>
	<view style="text-align: center;margin-bottom: 40rpx;">身份证正面</view>
	<!-- 反面 -->
	<jianweikaifa-idCardShooting 
	    :isFront="0" 
	    @idCardData="getIdCardData" 
	    @close="getClose">
	</jianweikaifa-idCardShooting>
	<view style="text-align: center;">身份证反面</view>
	
	
	<view class="confirm" v-if="url1!=''&&url0!=''">
		<button class="confirm-btn" @click="confirm">确认上传</button>
	</view>
	</view>
	

</template>

<script>
	// var cameraModule = uni.requireNativePlugin('yun-camerax-module');
	export default {
		data() {
			return {
				url1:"",
				url0:"",
				idCardData:[],
				init: false,
				src: ''
			}
		},
		methods: {
			confirm(){
				
			},
			getClose(){
				
			},
			getIdCardData(data){
				if(data.isFront==1){
					this.url1=data.tempFilePath
				}
				if(data.isFront==0){
					this.url0=data.tempFilePath
				}
				console.log(data.isFront)
				console.log(this.url1,this.url0)
			},
			takePhotoFront(imageIndex) {
				let _this = this;
				cameraModule.takePhoto({ type: 0, imageIndex: imageIndex }, res => {
					console.log(res);
					uni.showModal({
						title: '提示',
						content: JSON.stringify(res),
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					_this.src = 'file://' + res.file;
				});
			},
			//内置国徽面蒙版 0：蒙版第一张,1：蒙版第二张，2,蒙版第三张
			takePhotoBack(imageIndex) {
				let _this = this;
				cameraModule.takePhoto({ type: 1, imageIndex: imageIndex }, res => {
					console.log(res);
					uni.showModal({
						title: '提示',
						content: JSON.stringify(res),
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					_this.src = 'file://' + res.file;
				});
			}
		}
	}
</script>

<style>
.confirm{
	    position: absolute;
	    width: 100%;
	    bottom: 60px;
		display: flex;
		justify-content: center;
}
.confirm-btn{
	background-color: #039aff;
	color: #fff;
	width: 333px;
}
</style>
